﻿using Flatland.GeneticProgramming.CoreTypes;
using Flatland.GeneticProgramming.SyntaxTree;

namespace Flatland.GeneticProgramming.Initializations {
    /// <summary>
    /// Ramped half and half class.
    /// </summary>
    class RampedHalfAndHalf : IInitialization{
        readonly FullInitialization _fi = new FullInitialization();
        bool _grow;

        /// <summary>
        /// Build a tree using the Ramped half and half method.
        /// An instance of the class must be reused consequetly to work
        /// </summary>
        /// <param name="maxDepth"></param>
        /// <param name="primitiveSet"></param>
        /// <returns></returns>
        public Tree Init(uint maxDepth, PrimitiveSet primitiveSet){
            _grow = !_grow;
            return _fi.Init(maxDepth, primitiveSet, _grow);
        }
    }
}
